#pragma once
#include "BaseLayer.h"

class CIPLayer 
: public CBaseLayer  
{
private:
	inline void		ResetHeader( );

public:
	void			SetIPSrcAddr(BYTE, BYTE, BYTE, BYTE);
	void			SetIPDstAddr(BYTE, BYTE, BYTE, BYTE);

	BOOL			Send( unsigned char* ppayload, int nlength );
	BOOL			Receive( unsigned char* ppayload ) ;

	CIPLayer( char* pName );
	virtual ~CIPLayer();

	typedef struct _IP {

		unsigned char	ip_verlen;				// ip version
		unsigned char	ip_tos;					// type of service
		unsigned short	ip_length;				// total packet length
		unsigned short	ip_id;					// datagram id
		unsigned short	ip_fragoff;				// fragment offset
		unsigned char	ip_ttl;					// time of live, in gateway hops
		unsigned char	ip_proto;				// IP protocol
		unsigned short	ip_cksum;				// header checksum
		unsigned char	ip_src[4];				// IP address of source
		unsigned char	ip_dst[4];				// IP address of destination
		unsigned char	ip_data[IP_DATA_SIZE];	// variable length data

	} IP, *LPIP ;

protected:
	IP	m_sHeader ;
};